package com.ty.bigevent.mapper;

import com.ty.bigevent.model.entry.Category;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ty.bigevent.model.vo.CategoryVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author ong char
* @description 针对表【category】的数据库操作Mapper
* @createDate 2025-09-27 01:05:27
* @Entity com.ty.bigevent.model.entry.Category
*/
public interface CategoryMapper extends BaseMapper<Category> {

    @Insert("insert into category(category_name,category_alias,create_user,create_time,update_time) values(#{category_name},#{category_alias},#{create_user},now(),now())")
    void addCategory(Category category);

    @Select("select id, category_name, category_alias, create_time, update_time from category where create_user=#{userId}")
    List<CategoryVO> listCategory(@Param("userId") Integer userId);
    @Select("select id, category_name, category_alias, create_time, update_time from category where create_user=#{id}")
    CategoryVO getCategoryById(@Param("id") Integer id);

    @Update("update category set category_name=#{category_name},category_alias=#{category_alias},update_time=now() where id=#{id}")
    void updateCategory(Category category);

    @Delete("delete from category where id=#{id}")
    void deleteCategoryById(@Param("id") Integer id);
}




